<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/view/common/kendocommon.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <title>教师信息维护</title>
    <meta charset="utf-8">
    <style>
    	table{font-size:12px}
    </style>
    <script>
        $(document).ready(function() {
        	$("#toolbar").kendoToolBar({
	            resizable: false,
	            items: [
	            	{ type: "separator" },
	                //{ template: toolbarTemp},
					//{ type: "separator" },
	                //{ template: '<label>旗舰店:</label><input id="park" class="k-textbox"/>'},
	                //{ type: "separator" },
	                { type: "button", text: "刷新",click: queryInfoList }
	            ]
	        });
	        
            dataSource = new kendo.data.DataSource({
                transport: {
                    read:  {
                        url: "${path}/teacher/queryTearcherList",
                        dataType: "json"
                    }
                },
                //group: [{field: "businessTypeCode"}],
                serverPaging: true,
                serverFiltering: true,
                pageSize: 15,
                schema: {
                	data:"data",
               		total:"total"
                }
            });
            
            $("#grid").kendoGrid({
                dataSource: dataSource,
                //pageable: true,
                pageable: {
					refresh: true,
					pageSizes: true,
					buttonCount: 5,
					page: 1,
					pageSize: 10,
					pageSizes: [10, 20, 30],
					messages: {
						display: "显示 {0}-{1} 共 {2} 项",
						empty: "没有数据",
						itemsPerPage: "每面显示数量",
						first: "第一页",
						last: "最后一页",
						next: "下一页",
						previous: "上一页"
					}
				},
                selectable: "multiple row",
                allowCopy: true,
                groupable: {
                    messages: {
                      empty: "将列拖拽到此处进行分类查看"
                    }
                },
                //editable: 'incell',
                columns: [
                	{ field:"user_name", title: "用户名",width: "120px"},
                    { field:"sex", title: "性别",width: "80px",template:checksex},
                    { field:"email", title: "邮箱",width: "150px"},
                    { field:"birthday", title: "生日",width: "120px"},
                    { field:"mobil_no", title: "手机号",width: "100px"},
                    { field:"score", title: "评分",width: "80px"},
                    { field:"dept_name", title: "部门",width: "120px"},
                    { field:"p_name", title: "上级部门",width: "120px"},
                    //{ field: "UnitsInStock", title:"Units In Stock", width:"120px"},//,format:"{0:yyyy/MM/dd}"
                    { command: [{name:"editrow",text:"<span class='k-icon k-edit'></span>信息维护",click:queryInfo,buttonType:"ImageAndText"}], title: "操作", width: "100px" }
                    ]
            });
            $('#grid').css("height",document.body.clientHeight-38);
		});
        
		var checksex = function(dataItem){
			var sex = "";
			if(dataItem.sex==1){
				sex="女";
			}else{
				sex="男";
			}
			return sex;
		}
		
		var queryInfo = function(e){//编辑
			var grid = $("#grid").data("kendoGrid");
			e.preventDefault();
            var data = grid.dataItem($(e.currentTarget).closest("tr"));
            showInfo(data);
		}
		
		var queryInfoList = function(e){//查询
			$("#grid").data("kendoGrid").dataSource.fetch();
			$("#grid").data("kendoGrid").dataSource.page(1);
		}
		
		var saveParkProduct = function(e){
			$.ajax({
		        url: "${path}/assist/saveParkProduct",
		        dataType: 'json',
   				contentType: "application/json",
		        data: JSON.stringify(checkedArr),
		        type:"POST", 
		        success: function (text) {
		        	$("#grid").data("kendoGrid").dataSource.fetch();
		        	layer.msg(text.msg, {time: 3000, icon:6});
		        },
		        error: function (jqXHR, textStatus, errorThrown) {
		        	layer.msg("与远程服务器交互异常，请规范操作或重新登录", {time: 3000, icon:6});
		        }
		    });
		}
		
		var layIndex;
		var showInfo = function(data){
			var url = "${path}/teacher/queryTearcherDetail?user_id="+data.user_id+"&user_name="+data.user_name+"&birthday="+data.birthday+
					"&sex="+data.sex+"&dept_id="+data.dept_id+"&dept_name="+data.dept_name;
			layIndex = layer.open({
				title:"员工信息",
				//type: 1,
				type: 2,
				fix: false,
		        //shadeClose: true,
		        maxmin: true,
		        area: ['850px', '650px'], //宽高
			    //content: $('#inlineForm'),
			    content: url,
			    cancel: function(index){
			    	$("#grid").data("kendoGrid").dataSource.fetch();
		        }
			});
		}
		
    </script>
</head>
<body>
	<div id="toolbar" style="margin:2px"></div>
    <div id="grid" style="margin:2px;font-size:10px"></div>
</body>
</html>
